package com.hotelsystem.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * SpringMVC扩展功能配置类
 */
@Configuration
public class SpringMvcExtendConfiguration implements WebMvcConfigurer {



    /**
     * 添加路径映射
     * @param registry
     */
    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
        registry.addViewController("/").setViewName("login");
        registry.addViewController("/main.*").setViewName("main");
        registry.addViewController("/noAuth.html").setViewName("noAuth");
    }

    /**
     * 给新建的外部文件夹注册（赋予读/写权限）配置到springboot中即可
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        System.out.println("启动外部映射文件地址");
        registry.addResourceHandler("/static/**")
                .addResourceLocations("file:static/");
    }
     /**
     * 添加拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {

    }

}
